#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    string removeDuplicates(string s) {
        stack<char> st;
        for (auto e : s)
        {
            char t = st.top();
            if (!st.empty() && e == t)
            {
                st.pop();
                continue;
            }
            st.push(e);
        }
        string ret;
        while (!st.empty())
        {
            ret += st.top();
            st.pop();
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};